package com.wordpress.javagameengine.lazarek.dominik;


import java.awt.Graphics;
import java.awt.image.BufferedImage;

/**
 * This is your main-class pre-initialized with all methods you need to run your game. you just have to fill them ;-)
 * @author dommme
 *
 */
public class GameControl implements Runnable{

	
	boolean continueGame = false; //
	
	private GamePanel gamePanel; 	//the window of the game
	private Thread t; //the thread the game will run in
	
	private long currentFPS = 0;
	
	public GameControl()
	{
		this.t = new Thread(this);
		this.initializeGame();
		t.start();
	}
	
	private void initializeGame()
	{
		this.gamePanel = new GamePanel(50, 50, 800, 600, "Hello World!", this);
	}

	
	/**
	 * this is your game-loop. you have to add the code you wish to be launched every loop
	 */
	public synchronized void run()
	{
		while(this.continueGame)
		{
			currentFPS = gamePanel.calculateFramerate(); //updates the fps of your game
			gamePanel.repaint(); //calls draw(Graphics g) implicitly
		}
		
	}
	
	/**
	 * this method draws your sprites on the screen. Add Sprite- lists here
	 */
	public void draw(Graphics g)
	{
		
	}
	
	
	
	/**
	 * this method starts your game! After calling this method, your game intitializes the contents of the game 
	 * and starts to run the game- loop
	 */
	public void startGame()
	{
		this.initializeGame();
		this.t.start();
	}
	
		public static void main(String args[])
	{
		GameControl	yourGame = new GameControl();
	}
	
	

}
